home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / c_news / 16 / sets / setsourc / setmecnt.c < prev    next >
C/C++ Source or Header  |  1989-03-09  |  619b  |  29 lines

  1. #include <stdio.h>
  2. #include <stdarg.h>
  3. #include "sets.h"
  4. /***************************************************************************/
  5.              int set_member_count(set *aset)
  6. /***************************************************************************/
  7. /* Returns the number of members in a set */
  8. {
  9. int i,j,k;
  10. unsigned w;
  11.  
  12.     k = 0;
  13.     /* go through the member records and count the '1' bits */
  14.     for(i=0;i<aset->member_recs;i++)
  15.         {
  16.         w = 1;
  17.         for(j=0;j<MEMBERS_PER_WORD;j++)
  18.             {
  19.             if((aset->word[i] & w) > 0)
  20.                 k++;
  21.             w = w << 1;
  22.             }
  23.         }
  24.  
  25.     return k;
  26.  
  27. }  /* end set_member_count */
  28.  
  29.